s=input()
a,b=input().split()
len1=0
arr=[]
for i in range(len(s)):
    if s[i]==a:
        arr=arr+[i]
        len1+=1
    elif s[i]==b:
        arr=arr+[i]
        len1+=1
        
arr.reverse()
for i in arr:
    print("%d %c"%(int(i),s[int(i)]))